<?php

namespace app\models;

use Yii;
use yii\helpers\Html;
use yii\helpers\ArrayHelper;
/**
 * This is the model class for table "rah_combox".
 *
 * @property integer $comboxID
 * @property string $comboxName
 * @property string $itemName
 * @property string $itemValue
 * @property integer $orderNo
 */
class Combox extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'rah_combox';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['orderNo'], 'integer'],
            [['comboxName'], 'string', 'max' => 20],
            [['itemName', 'itemValue'], 'string', 'max' => 100],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'comboxID' => 'Combox ID',
            'comboxName' => 'Combox Name',
            'itemName' => 'Item Name',
            'itemValue' => 'Item Value',
            'orderNo' => 'Order No',
        ];
    }
    
    public static function getCombox($comboxName=''){
        if(!empty($comboxName)){
            $model = self::find()->where(['comboxName'=>$comboxName])->all();
            $_arr = ArrayHelper::map($model, 'itemName', 'itemValue');
            return $_arr;
        }
    }
}
